
package com.netease.xone.view;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.netease.xone.R;

public class SettingItemView extends LinearLayout {

    private Context mContext;
    private TextView mItemTitle;
    private TextView mItemDes;
    private TextView mItemBtn;
    private LinearLayout mlay;

    public SettingItemView(Context context) {
        super(context);
        init(context);
    }

    public SettingItemView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public SettingItemView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init(context);
    }

    private void init(Context context) {
        mContext = context;
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        mItemTitle = (TextView)findViewById(R.id.setting_title);
        mItemDes = (TextView)findViewById(R.id.setting_description);
        mItemBtn = (TextView)findViewById(R.id.setting_btn);
    }

    public void setTitleText(String title) {
        if(mItemTitle != null){
            mItemTitle.setText(title);
        }
    }

    public void setDesText(String des) {
        if (mItemDes != null) {
            if (!TextUtils.isEmpty(des)) {
                mItemDes.setText(des);
                mItemDes.setVisibility(View.VISIBLE);
            } else {
                mItemDes.setVisibility(View.GONE);
            }
        }
    }

    public void setBtnText(String btn) {
        if (mItemBtn != null) {
            if (!TextUtils.isEmpty(btn)) {
                mItemBtn.setText(btn);
                mItemBtn.setVisibility(View.VISIBLE);
            } else {
                mItemBtn.setVisibility(View.GONE);
            }
        }
    }
}
